home *** CD-ROM | disk | FTP | other *** search
/ Introduction to 3D Game …ogramming with DirectX 12 / Introduction-to-3D-Game-Programming-with-DirectX-12.ISO / Code.Textures / Chapter 13 The Compute Shader / SobelFilter / Shaders / Composite.hlsl < prev    next >
Encoding:
Text File  |  2016-03-02  |  1.3 KB  |  54 lines

  1. //***************************************************************************************
  2. // Composite.hlsl by Frank Luna (C) 2015 All Rights Reserved.
  3. //
  4. // Combines two images.
  5. //***************************************************************************************
  6.  
  7. Texture2D gBaseMap : register(t0);
  8. Texture2D gEdgeMap : register(t1);
  9.  
  10. SamplerState gsamPointWrap        : register(s0);
  11. SamplerState gsamPointClamp       : register(s1);
  12. SamplerState gsamLinearWrap       : register(s2);
  13. SamplerState gsamLinearClamp      : register(s3);
  14. SamplerState gsamAnisotropicWrap  : register(s4);
  15. SamplerState gsamAnisotropicClamp : register(s5);
  16.  
  17. static const float2 gTexCoords[6] = 
  18. {
  19.     float2(0.0f, 1.0f),
  20.     float2(0.0f, 0.0f),
  21.     float2(1.0f, 0.0f),
  22.     float2(0.0f, 1.0f),
  23.     float2(1.0f, 0.0f),
  24.     float2(1.0f, 1.0f)
  25. };
  26.  
  27. struct VertexOut
  28. {
  29.     float4 PosH    : SV_POSITION;
  30.     float2 TexC    : TEXCOORD;
  31. };
  32.  
  33. VertexOut VS(uint vid : SV_VertexID)
  34. {
  35.     VertexOut vout;
  36.     
  37.     vout.TexC = gTexCoords[vid];
  38.     
  39.     // Map [0,1]^2 to NDC space.
  40.     vout.PosH = float4(2.0f*vout.TexC.x - 1.0f, 1.0f - 2.0f*vout.TexC.y, 0.0f, 1.0f);
  41.  
  42.     return vout;
  43. }
  44.  
  45. float4 PS(VertexOut pin) : SV_Target
  46. {
  47.     float4 c = gBaseMap.SampleLevel(gsamPointClamp, pin.TexC, 0.0f);
  48.     float4 e = gEdgeMap.SampleLevel(gsamPointClamp, pin.TexC, 0.0f);
  49.     
  50.     return c*e;
  51. }
  52.  
  53.  
  54.